package indi.lddsdu.spider.bean;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

/**
 * Created by jack on 18/6/4.
 */
public class RuntimeParameter {
    static Logger logger = LoggerFactory.getLogger(RuntimeParameter.class);

    public static String domain = "http://www.view.sdu.edu.cn";
    public static String persistenceHtmlFolder = "/Users/jack/Desktop/htmlView/";
    public static String persistenceImageFolder = "/Users/jack/Desktop/imgView/";

    static{
        File file = new File(persistenceHtmlFolder);
        createFolder(file);
        file = new File(persistenceImageFolder);
        createFolder(file);
    }

    private static void createFolder(File file) {
        if (file.exists()){
            logger.info(persistenceHtmlFolder + " already exists");
        }else{
            logger.info(persistenceHtmlFolder + " don't exist, will create it");
            file.mkdirs();
        }
    }

    public static void setPersistenceHtmlFolder(String persistenceHtmlFolder) {
        RuntimeParameter.persistenceHtmlFolder = persistenceHtmlFolder;
    }

    public static void setPersistenceImageFolder(String persistenceImageFolder) {
        RuntimeParameter.persistenceImageFolder = persistenceImageFolder;
    }
}
